; /////////////////////////////////////////////////////////////////////////////
;
;     This file is part of PurePicBasic.
; 
;     PurePicBasic is free software: you can redistribute it And/Or modify
;     it under the terms of the GNU General Public License As published by
;     the Free Software Foundation, either version 3 of the License, Or
;     (at your option) any later version.
; 
;     PurePicBasic is distributed in the hope that it will be useful,
;     but WITHOUT ANY WARRANTY; without even the implied warranty of
;     MERCHANTABILITY Or FITNESS For A PARTICULAR PURPOSE.  See the
;     GNU General Public License For more details.
; 
;     You should have received a copy of the GNU General Public License
;     along With PurePicBasic.  If Not, see <http://www.gnu.org/licenses/>.
;
; /////////////////////////////////////////////////////////////////////////////

; /////////////////////////////////////////////////////////////////////////////
;
; /////////////////////////////////////////////////////////////////////////////
Procedure _compiler_check_()
  
  If ListSize(_error_message_lst_()) = #MAX_ERROR 
    generate_final_code = #False
    too_many_error      = #True 
  EndIf   
    
  If ListSize(_warning_message_lst_()) = #MAX_WARNING
    generate_final_code = #False
    too_many_warning    = #True 
  EndIf   
    
  
  If too_many_error = #True 
    
    PrintN("")
    PrintN("Too many errors ("+Str(ListSize(_error_message_lst_()))+") , compiler stop.")
    PrintN("")
    
    ForEach _error_message_lst_()
      PrintN(_error_message_lst_())
    Next 
    
    PrintN("")
    
    
    If ListSize(_warning_message_lst_())>0
      ForEach _warning_message_lst_()
        PrintN(_warning_message_lst_())
      Next 
      
      PrintN("")
    EndIf 
    
    End 
    
  EndIf 
  
  
  If too_many_warning = #True 
    
    PrintN("")
    PrintN("Too many warnings ("+Str(ListSize(_warning_message_lst_()))+") , compiler stop.")
    PrintN("")
    
    ForEach _warning_message_lst_()
      PrintN(_warning_message_lst_())
    Next 
    
    PrintN("")
    
    End 
    
  EndIf 
  
EndProcedure

; /////////////////////////////////////////////////////////////////////////////
;
; /////////////////////////////////////////////////////////////////////////////
Procedure _warning_message_(message.s, file.s, line.i)
  AddElement(_warning_message_lst_())
  nbWarning + 1
  _warning_message_lst_() = "In file "+file+" : "
  AddElement(_warning_message_lst_())
  _warning_message_lst_() = "Warning at line "+Str(line)+" : " + message
  _compiler_check_()
EndProcedure

; /////////////////////////////////////////////////////////////////////////////
;
; /////////////////////////////////////////////////////////////////////////////
Procedure _error_message_(message.s, file.s, line.i)
  generate_final_code = #False
  nbError + 1
  AddElement(_error_message_lst_())
  _error_message_lst_() = "In file "+file+" : "
  AddElement(_error_message_lst_())
  _error_message_lst_() = "Error at line "+Str(line)+" : " + message
  _compiler_check_()
EndProcedure

; /////////////////////////////////////////////////////////////////////////////
;
; /////////////////////////////////////////////////////////////////////////////
Procedure _compiler_status_()
  
  PrintN("")
  PrintN(RSet("",79,"-"))
  PrintN("Compiler finished ! Error : "+Str(nbError)+" Warning : "+Str(nbWarning)) 
  PrintN(RSet("",79,"-"))
  
  
   If nbWarning>0
      ForEach _warning_message_lst_()
        PrintN(_warning_message_lst_())
      Next 
   EndIf 
  
   If nbError>0
      ForEach _error_message_lst_()
        PrintN(_error_message_lst_())
      Next 
   EndIf 
  
  
EndProcedure
